/*
 * tda1543.c
 *
 * Created: 2011.10.26 20:58:28
 *  Author: Administrator
 */ 

#include "tda1543.h"

void TDA1543_init()
{
	DDRA|=7;
}

void TDA1543_left_channel()
{
	TDA1543_PORT&=~(1<<TDA1543_WS);
}
void TDA1543_right_channel()
{
	TDA1543_PORT|= (1<<TDA1543_WS);
}

void TDA1543_output(unsigned short ldata,unsigned short rdata)
{
	unsigned char i;
	short d=20;
	
	TDA1543_left_channel();
	TDA1543_PORT|=1<<TDA1543_DATA;
	for (i=0;i<16;i++)
	{
		TDA1543_PORT&=~(1<<TDA1543_BCK);
		_delay_us(d);
		TDA1543_PORT|= (1<<TDA1543_BCK);
		_delay_us(d);
	}
	
	TDA1543_right_channel();
	TDA1543_PORT&=~(1<<TDA1543_DATA);
	for (i=0;i<16;i++)
	{
		TDA1543_PORT&=~(1<<TDA1543_BCK);
		_delay_us(d);
		TDA1543_PORT|= (1<<TDA1543_BCK);
		_delay_us(d);
	}
}